﻿using System.Collections;
using UnityEngine;
using XLua_Ki;

public class CreatePanel_Demo : MonoBehaviour {

    void Start () {
        string mainABRoot = Application.dataPath + @"\XLua\MiniKimmy\Examples\01_CreatePanel\streamingassets\MiniKimmy_CreatePanel\";

        GameObject obj = new GameObject("MiniKimmy");
        obj.AddComponent<GameManager_Ki>();
        DontDestroyOnLoad(obj);

        StartCoroutine(TestCreatePanel(mainABRoot));
	}

    IEnumerator TestCreatePanel(string mainABRoot)
    {
        GameManager_Ki.Instance.GetResourcesManager_Ki().LoadALLABPrefabs(mainABRoot);

        Debug.Log("MiniKimmy : wait for 3s ...");
        int wait = 0;
        while (wait++ < 3)
        {
            Debug.Log("MiniKimmy :" + (3 - wait) + "...");
            yield return new WaitForSeconds(1f);
        }

        LuaUtil.CallLuaPathAction(GameManager_Ki.Instance.LuaEnv, "PanelRegister.CreatePanels", UnityEngine.SceneManagement.SceneManager.GetActiveScene().name);
    }


}
